package com.fch.sdlibrary.util;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.fch.sdlibrary.R;
import com.fch.sdlibrary.entity.BookClazz;

import java.util.List;

public class BookClazzAdapter extends BaseAdapter {
    private List<BookClazz> mData;//定义数据。
    private LayoutInflater mInflater;//定义Inflater,加载我们自定义的布局。

    public BookClazzAdapter(List<BookClazz> mData, LayoutInflater mInflater) {
        this.mData = mData;
        this.mInflater = mInflater;
    }

    @Override
    public int getCount() {
        return mData.size();
    }

    @Override
    public Object getItem(int i) {
        return mData.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        View viewBookClazz = mInflater.inflate(R.layout.bookclazz_item, null);

        if (viewBookClazz != null) {
            TextView textView = viewBookClazz.findViewById(R.id.book_class_name);
            textView.setText(mData.get(i).getClassificationName());
        }
        return viewBookClazz;
    }
}